package com.example.swimmingpool.controller.notice;

import com.example.swimmingpool.entity.notice.Notice;
import com.example.swimmingpool.response.CommonResponse;
import com.example.swimmingpool.service.notice.NoticeService;
import com.example.swimmingpool.vo.notice.NoticeVo;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/notice")
public class NoticeController {
    @Resource
    private NoticeService noticeService;

    @PostMapping("/add")
    public CommonResponse<Boolean> insert(@RequestBody Notice notice) {
        return CommonResponse.success(noticeService.insert(notice));
    }

    @PostMapping("/list")
    public CommonResponse<List<Notice>> list() {
        return CommonResponse.success(noticeService.list());
    }

    @PostMapping("/delete")
    public CommonResponse<Boolean> delete(@RequestBody NoticeVo vo) {
        return CommonResponse.success(noticeService.delete(vo.getId()));

    }

    @PostMapping("/update")
    public CommonResponse<Boolean> update(@RequestBody NoticeVo vo) {
        return CommonResponse.success(noticeService.update(vo));
    }
}
